<template>
  <el-dialog
    title="请选择签名类型"
    :visible.sync="dialogVisible"
    width="60%"
    :before-close="handleClose"
    append-to-body
    :close-on-click-modal="false"
    :close-on-press-escape="false"
  >
    <div class="sign-ul">
      <div
        class="sign-li"
        v-for="(item, index) in outSignList"
        :key="index"
        @click="selectSign(item)"
      >
        <div class="img-box" :style="{ backgroundColor: item.color }">
          <img :src="item.img" :alt="item.name" />
        </div>

        <div class="text">
          {{ item.name }}
        </div>
      </div>
    </div>
    <template #footer>
      <el-button type="info" @click="handleClose"> 取 消 </el-button>
    </template>
  </el-dialog>
</template>

<script>
import { signModalData } from "./options";

export default {
  name: "WorkspaceJsonSignmodal",

  props: {
    value: {
      type: [Boolean],
      default: false
    },
    signList: {
      type: [Array],
      default: () => {
        return [];
      }
    }
  },

  inject: ["designerConfig"],

  data() {
    return {
      dialogVisible: false
    };
  },

  computed: {
    outSignList() {
      let arr = [];
      signModalData.forEach(item => {
        if (!this.injectConfig.tagType) {
          return;
        }
        this.injectConfig.tagType.forEach(_item => {
          if (item.key === _item) {
            arr.push(item);
          }
        });
      });
      return arr;
    },
    injectConfig() {
      return this.designerConfig();
    }
  },

  watch: {
    value(n) {
      this.dialogVisible = n;
    }
  },

  mounted() {},

  methods: {
    selectSign(item) {
      this.$emit("selectSign", item);
    },
    handleClose() {
      this.$emit("input", false);
    }
  }
};
</script>

<style lang="scss" scoped>
.sign-ul {
  display: flex;
  align-items: center;
  justify-content: space-around;
  .sign-li {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    .img-box {
      border-radius: 50%;
      width: 60px;
      height: 60px;
      box-sizing: border-box;
      padding: 10px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .text {
      margin-top: 20px;
    }
  }
}
</style>
